import { getCurrentInstance } from 'vue'
function useInstance (target) {
  const Instance = getCurrentInstance();
  const Properties = Instance.appContext.config.globalProperties;
  return target ? Properties[target] : Properties
}

function create_uuid () {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
    return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
  })
}

function loop(m, c) {
  return m.find(e => e.id === c ? e : loop(e.children, c));
}

export {
  useInstance,
  create_uuid,
  loop,
}